<?php
ob_start();
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('u_jb_list',$QXARR))exit(noauth());
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'sub/ZeaiUP.php';
$FT=json_decode(FT,true);
function photo_tmp_m($V){
	if(strstr($V,'/tmp/') && !empty($V)){
		$_s=adm_pic_reTmpDir_send($V,'m');
		adm_pic_reTmpDir_send(smb($V,'m'),'m');
		adm_pic_reTmpDir_send(smb($V,'b'),'m');
		adm_pic_reTmpDir_send(smb($V,'blur'),'m');
		//
		$path_m_old = smb($V,'m');
		$path_b_old = smb($V,'b');
		$path_blue_old = smb($V,'blur');
		@up_send_admindel($V.'|'.$path_m_old.'|'.$path_b_old.'|'.$path_blue_old);
		return $_s;
	}else{
		return $V;
	}
}
switch ($submitok) {
	case"photo_s_shalou_del":
		$uid=intval($uid);
		//
		$row = $db->ROW(__TBL_SHALOU__,"jsonstr","uid=".$uid,"name");
		if (!$row)alert_adm("沙漏数据丢失","back");
		$row_shalou = json_decode($row['jsonstr'],true);
		$path_s_new = $row_shalou['photo_s'];
		//
		$row = $db->ROW(__TBL_USER__,"photo_s,nickname,openid,subscribe,magapp_uid","id=".$uid);
		if ($row){
			$path_s = $row[0];$data_nickname = trimhtml(dataIO($row[1],'out'));$data_openid = $row[2];$data_subscribe = $row[3];$magapp_uid = $row[4];
			if ($path_s!=$path_s_new){
				$path_m_new = smb($path_s_new,'m');$path_b_new = smb($path_s_new,'b');$path_blue_new = smb($path_s_new,'blur');
				@up_send_admindel($path_s_new.'|'.$path_m_new.'|'.$path_b_new.'|'.$path_blue_new);
			}
			$row_shalou['photo_s']='';
			$row_shalou=encode_json($row_shalou);
			$db->query("UPDATE ".__TBL_SHALOU__." SET jsonstr='$row_shalou' WHERE uid=".$uid);

			AddLog('审核驳回并删除用户【'.$data_nickname.'（uid:'.$uid.'）】头像');
			//站内消息
			$C = $data_nickname.'您好，您的头像未通过审核，请重新上传本人照片';
			$db->SendTip($uid,"您的头像未通过审核",dataIO($C,'in'),'sys');
			//微信模版
			//if (!empty($data_openid) && $data_subscribe==1){
				$keyword1 = urlencode('审核未通过');
				$keyword2 = urlencode('头像不符合规范，原因（不是本人或照片太小不清晰），进入重新上传');
				$url      = urlencode(mHref('my_info'));
				@wx_mb_sent('mbbh=ZEAI_DATA_CHECK&magapp_uid='.$magapp_uid.'&openid='.$data_openid.'&keyword1='.$keyword1.'&keyword2='.$keyword2.'&first='.$first.'&remark='.$remark.'&url='.$url);
			//}
		}
		json_exit(array('flag'=>1,'msg'=>'操作成功'));
	break;
	case"dataflag1":
		if(empty($list))json_exit(array('flag'=>0,'msg'=>'请选择您要审核的信息'));
		if(!is_array($list))exit(JSON_ERROR);
		if(count($list)>=1){
			foreach($list as $uid){
				$uid=intval($uid);
				$row = $db->ROW(__TBL_SHALOU__,"*","uid=".$uid);
				if (!$row)alert_adm("沙漏数据丢失","back");
				$row_shalou=json_decode($row['jsonstr'],true);
				unset($row_shalou['mob']);
				//
				$row = $db->ROW(__TBL_USER__,"nickname,openid,subscribe,photo_s,magapp_uid","id=".$uid,"num");
				$data_photo_s=$row[3];
				if ($row){
					//沙漏资料同步
					$SQL='';
					if (count($row_shalou) >= 1 && is_array($row_shalou)){
						foreach ($row_shalou as $k=>$V) {
							if($V=='undefined')$V=0;
							if(ifInTableF($k)){
								if($FT[$k]['s']==2)$V=intval($V);
								if($k=='photo_s' && $photo_sflag1==1){
									$V=photo_tmp_m($V);$row_shalou[$k]=$V;
									//删老
									if(!empty($data_photo_s) && $data_photo_s!=$V && !empty($V)){
										@up_send_userdel($data_photo_s.'|'.smb($data_photo_s,'m').'|'.smb($data_photo_s,'b').'|'.smb($data_photo_s,'blur'));
									}
								}
								if($k=='birthday' && !ifdate($V)){$V='0000-00-00';$row_shalou[$k]=$V;}
								$SQL.=",$k='$V'";
							}else{
								unset($row_shalou[$k]);
								$new_row_shalou=encode_json($row_shalou);
								$db->query("UPDATE ".__TBL_SHALOU__." SET jsonstr='$new_row_shalou' WHERE uid=".$uid);
							}
						}
					}
					$new_row_shalou=encode_json($row_shalou);
					$db->query("UPDATE ".__TBL_SHALOU__." SET jsonstr='$new_row_shalou',photo_f=1 WHERE uid=".$uid);
					//
					$db->query("UPDATE ".__TBL_USER__." SET dataflag=1".$SQL." WHERE id=".$uid);
					$db->query("UPDATE ".__TBL_USER__." SET photo_f=1 WHERE photo_s<>'' AND id=".$uid);
					set_data_ed_bfb($uid);
					$data_nickname = dataIO($row[0],'out');$data_openid = $row[1];$data_subscribe = $row[2];$magapp_uid = $row[4];
					AddLog('【资料审核】->【'.$data_nickname.'（uid:'.$id.'）】->通过');
					//站内消息
					$C = $data_nickname.'恭喜你！个人资料已通过审核';
					$db->SendTip($uid,"恭喜你！个人资料已通过审核",dataIO($C,'in'),'sys');
					//微信模版
					//if (!empty($data_openid) && $data_subscribe==1){
						$keyword1 = urlencode('已通过');
						$keyword2 = urlencode('个人资料符合规范');
						$url      = urlencode(mHref('my'));
						@wx_mb_sent('mbbh=ZEAI_DATA_CHECK&magapp_uid='.$magapp_uid.'&openid='.$data_openid.'&keyword1='.$keyword1.'&keyword2='.$keyword2.'&first='.$first.'&remark='.$remark.'&url='.$url);
					//}
				}
			}
		}
		json_exit(array('flag'=>1,'msg'=>'审核成功'));
	break;
	case"dataflag1_update":
		$uid=intval($uid);
		$row = $db->ROW(__TBL_SHALOU__,"*","uid=".$uid);
		if (!$row)alert_adm("沙漏数据丢失","back");
		$row_shalou=json_decode($row['jsonstr'],true);
		//
		$row = $db->ROW(__TBL_USER__,"nickname,openid,subscribe,photo_s,magapp_uid","id=".$uid,"num");
		if ($row){
			$data_photo_s=$row[3];
			
			//跟进入库
			//if(str_len($content)<1)json_exit(array('flag'=>0,'msg'=>'请输入【审核意见】','focus'=>'content'));
			$nexttime = 0;$intention=4;$content = dataIO($content,'in',1000);
			$row2 = $db->ROW(__TBL_USER__,"agentid,agenttitle","id=".$uid,'num');$agentid= $row2[0];$agenttitle= $row2[1];
			if(!ifint($agentid) || empty($agenttitle)){
				$agentid=intval($session_agentid);
				$agenttitle=$session_agenttitle;
			}
			if(!empty($pathlist)){
				$ARR=explode(',',$pathlist);
				if (count($ARR) >= 1 && is_array($ARR)){
					$pathlist=array();
					foreach ($ARR as $V) {
						adm_pic_reTmpDir_send($V,'crm');
						adm_pic_reTmpDir_send(smb($V,'b'),'crm');
						$path_s = str_replace('tmp','crm',$V);
						$pathlist[]=$path_s;
					}
					$pathlist = implode(',',$pathlist);
				}
			}
			if(!empty($content) || !empty($pathlist)){
				$sqflag=1;
				$db->query("INSERT INTO ".__TBL_CRM_BBS__."  (uid,content,addtime,admid,admname,agentid,agenttitle,nexttime,intention,pathlist,sqflag) VALUES ($uid,'$content',".ADDTIME.",$session_uid,'$session_truename','$agentid','$agenttitle','$nexttime','$intention','$pathlist','$sqflag')");
			}
			//沙漏资料同步
			if($photo_sflag1!=1){
				unset($row_shalou['photo_s']);
			}else{
				$db->query("UPDATE ".__TBL_USER__." SET photo_f=1 WHERE id=".$uid);
			}
			unset($row_shalou['mob']);
			$SQL='';
			if (count($row_shalou) >= 1 && is_array($row_shalou)){
				foreach ($row_shalou as $k=>$V) {
					if($V=='undefined')$V=0;
					if(ifInTableF($k)){
						if($FT[$k]['s']==2)$V=intval($V);
						if($k=='photo_s' && $photo_sflag1==1){
							$V=photo_tmp_m($V);$row_shalou[$k]=$V;
							//删老
							if(!empty($data_photo_s) && $data_photo_s!=$V && !empty($V)){
								@up_send_userdel($data_photo_s.'|'.smb($data_photo_s,'m').'|'.smb($data_photo_s,'b').'|'.smb($data_photo_s,'blur'));
							}
						}
						if($k=='birthday' && !ifdate($V)){$V='0000-00-00';$row_shalou[$k]=$V;}
						$SQL.=",$k='$V'";
					}else{
						unset($row_shalou[$k]);
						$new_row_shalou=encode_json($row_shalou);
						$db->query("UPDATE ".__TBL_SHALOU__." SET jsonstr='$new_row_shalou' WHERE uid=".$uid);
					}
				}
			}
			$new_row_shalou=encode_json($row_shalou);
			$db->query("UPDATE ".__TBL_SHALOU__." SET jsonstr='$new_row_shalou',photo_f=1 WHERE uid=".$uid);
			//
			$db->query("UPDATE ".__TBL_USER__." SET dataflag=1".$SQL." WHERE id=".$uid);
			set_data_ed_bfb($uid);
			$data_nickname = dataIO($row[0],'out');$data_openid = $row[1];$data_subscribe = $row[2];$magapp_uid = $row[4];
			AddLog('【资料审核】->【'.$data_nickname.'（uid:'.$id.'）】->通过');
			//站内消息
			$C = $data_nickname.'恭喜你！个人资料已通过审核';
			$db->SendTip($uid,"恭喜你！个人资料已通过审核",dataIO($C,'in'),'sys');
			//微信模版
			//if (!empty($data_openid) && $data_subscribe==1){
				//审核通过提醒
				$keyword1 = urlencode('已通过');
				$keyword2 = urlencode('个人资料符合规范');
				$url      = urlencode(mHref('my'));
				@wx_mb_sent('mbbh=ZEAI_DATA_CHECK&magapp_uid='.$magapp_uid.'&openid='.$data_openid.'&keyword1='.$keyword1.'&keyword2='.$keyword2.'&first='.$first.'&remark='.$remark.'&url='.$url);
			//}
		}
		json_exit(array('flag'=>1,'msg'=>'操作成功'));
	break;
	case"dataflag2_update":
		$id=intval($uid);
		$row = $db->ROW(__TBL_USER__,"nickname,openid,subscribe,magapp_uid","id=".$id,"num");
		if ($row){
			//跟进入库
			//if(str_len($content)<1)json_exit(array('flag'=>0,'msg'=>'请输入【审核意见】','focus'=>'content'));
			$nexttime = 0;$intention=4;$content = dataIO($content,'in',1000);
			$row2 = $db->ROW(__TBL_USER__,"agentid,agenttitle","id=".$uid,'num');$agentid= $row2[0];$agenttitle= $row2[1];
			if(!ifint($agentid) || empty($agenttitle)){
				$agentid=intval($session_agentid);
				$agenttitle=$session_agenttitle;
			}
			if(!empty($pathlist)){
				$ARR=explode(',',$pathlist);
				if (count($ARR) >= 1 && is_array($ARR)){
					$pathlist=array();
					foreach ($ARR as $V) {
						adm_pic_reTmpDir_send($V,'crm');
						adm_pic_reTmpDir_send(smb($V,'b'),'crm');
						$path_s = str_replace('tmp','crm',$V);
						$pathlist[]=$path_s;
					}
					$pathlist = implode(',',$pathlist);
				}
			}
			if(!empty($content) || !empty($pathlist)){
				$sqflag=2;
				$db->query("INSERT INTO ".__TBL_CRM_BBS__."  (uid,content,addtime,admid,admname,agentid,agenttitle,nexttime,intention,pathlist,sqflag) VALUES ($uid,'$content',".ADDTIME.",$session_uid,'$session_truename','$agentid','$agenttitle','$nexttime','$intention','$pathlist','$sqflag')");
				//更进结束
			}
			$db->query("UPDATE ".__TBL_USER__." SET dataflag=2 WHERE dataflag<>2 AND id=".$id);
			$db->query("UPDATE ".__TBL_SHALOU__." SET photo_f=1 WHERE uid=".$id);
			$data_nickname = dataIO($row[0],'out');$data_openid = $row[1];$data_subscribe = $row[2];$magapp_uid = $row[3];
			AddLog('【资料审核】->【'.$data_nickname.'（uid:'.$id.'）】->驳回');

			$title_def     = "对不起！个人基本资料审核失败！";
			$content_def   = "个人资料审核失败！请检查以下信息：<br>";
			$content_def  .= "　　1.基本资料不完善或不真实<br>";
			$content_def  .= "　　2.个人头像不是本人或未上传<br>";
			$content_def  .= "　　<a href=".Href('my_info')." class=aQING target=_blank>修改基本资料</a>　<a href=".Href('my_info')." class=aQING target=_blank>上传头像</a>";
			//站内消息
			$C = $content_def;
			$db->SendTip($uid,$title_def,dataIO($C,'in'),'sys');
			//微信模版
			//if (!empty($data_openid) && $data_subscribe==1){
				$keyword1 = urlencode('未通过');
				$keyword2 = urlencode('请重点检查【1.基本资料不完善或不真实 2.个人头像不是本人或未上传】');
				$url      = urlencode(mHref('my_info'));
				@wx_mb_sent('mbbh=ZEAI_DATA_CHECK&magapp_uid='.$magapp_uid.'&openid='.$data_openid.'&keyword1='.$keyword1.'&keyword2='.$keyword2.'&first='.$first.'&remark='.$remark.'&url='.$url);
			//}
		}
		json_exit(array('flag'=>1,'msg'=>'操作成功'));
	break;
	case"dataflag2":
		if(empty($list))json_exit(array('flag'=>0,'msg'=>'请选择您要驳回的信息'));
		if(!is_array($list))exit(JSON_ERROR);
		if(count($list)>=1){
			foreach($list as $id){
				$id=intval($id);$uid=$id;
				$row = $db->ROW(__TBL_USER__,"nickname,openid,subscribe,magapp_uid","id=".$id,"num");
				if ($row){
					$db->query("UPDATE ".__TBL_USER__." SET dataflag=2 WHERE dataflag<>2 AND id=".$id);
					$db->query("UPDATE ".__TBL_SHALOU__." SET photo_f=1 WHERE uid=".$id);
					$data_nickname = dataIO($row[0],'out');$data_openid = $row[1];$data_subscribe = $row[2];$magapp_uid = $row[3];
					AddLog('【资料审核】->【'.$data_nickname.'（uid:'.$id.'）】->驳回');

					$title_def     = "对不起！个人基本资料审核失败！";
					$content_def   = "个人资料审核失败！请检查以下信息：<br>";
					$content_def  .= "　　1.基本资料不完善或不真实<br>";
					$content_def  .= "　　2.个人头像不是本人或未上传<br>";
					$content_def  .= "　　<a href=".Href('my_info')." class=aQING target=_blank>修改基本资料</a>　<a href=".Href('my_info')." class=aQING target=_blank>上传头像</a>";

					//站内消息
					$C = $content_def;
					$db->SendTip($uid,$title_def,dataIO($C,'in'),'sys');
					
					//微信模版
					//if (!empty($data_openid) && $data_subscribe==1){
						//审核通过提醒
						$keyword1 = urlencode('未通过');
						$keyword2 = urlencode('请重点检查【1.基本资料不完善或不真实 2.个人头像不是本人或未上传】');
						$url      = urlencode(mHref('my_info'));
						@wx_mb_sent('mbbh=ZEAI_DATA_CHECK&magapp_uid='.$magapp_uid.'&openid='.$data_openid.'&keyword1='.$keyword1.'&keyword2='.$keyword2.'&first='.$first.'&remark='.$remark.'&url='.$url);
					//}
					
				}
			}
		}
		json_exit(array('flag'=>1,'msg'=>'驳回成功'));
	break;
}
require_once ZEAI.'cache/udata.php';
$extifshow   = json_decode($_UDATA['extifshow'],true);
$udata_F_arr = udata_arr('basic_ext');
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script>
function UdataSaveTip() {
	zeai.iframe('用户手机端保存资料后提示语','u_jb_list'+zeai.ajxext+'submitok=UdataSaveTip',600,400);
}
function shset() {
	zeai.iframe('审核设置','u_jb_list'+zeai.ajxext+'submitok=shset',500,420);
}
</script>
</head>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>
.tablelist{width:100%;margin:0}
a.noU58{width:60px;height:75px;position:relative;line-height:75px;border-radius:0;background:none}
a.noU58 img{margin-top:-3px;vertical-align:middle;width:60px;max-height:75px;background-color}
a.noU58 span{display:block;width:100%;line-height:24px;position:absolute;top:29px;background-color:rgba(0,0,0,0.4);color:#ccc;font-size:12px}
.datali li{line-height:150%;display:inline-block;padding:5px;border:#ddd 1px solid;margin:3px;border-radius:3px;color:#888}
.mate li{color:#5EB87B;border-color:#A7CAB2}
.photombox{width:60px;margin:10px auto;position:relative}
.photombox .del{background-image:url('images/picadd.png?3');background-size:120px 80px;background-repeat:no-repeat;width:20px;height:20px;top:-10px;right:-10px;position:absolute;border-radius:10px;background-position:-80px top;display:block;box-shadow:0 0 5px rgba(0,0,0,0.3)}
.photombox .del:hover{background-position:-100px top;cursor:pointer}
.forcerz{margin-top:10px;display:block;vertical-align:middle}
i.wxlv{color:#31C93C;margin-right:2px}
td.jt {text-align:center}
td.jt i{color:#bbb;font-size:18px;}
a.noU58,a.noU58:hover{border:0}
a.noU58 img{border-radius:2px}
a.cut{margin:0 auto}
.shsetli{margin:10px 0}
.box{padding:0;min-width:1000px;}
</style>
<body<?php if (!empty($submitok)){echo ' class="body"';}?>>
<?php if ($submitok == 'bz'){
	$p=intval($p);
	$uid=intval($uid);?>
	<form id="GYLform">
    <table class="table W95_ Mtop20" style="margin:15px 0 0 15px;">
    <?php if ($kind == 'dataflag1'){
		$btn_str='通过';
		$btn_cls='LV';
		$btn_confirm='通过审核后将覆盖更新原资料，并同步发送公众号和站内信审核成功信息';
		?>
    <tr>
    <td class="tdL">头像处理</td>
    <td class="tdR"><input type="checkbox" id="photo_sflag1" name="photo_sflag1" class="checkskin checkboxall" value="1" checked><label for="photo_sflag1" class="checkskin-label"><i></i><b class="W80 S14 Cf00">覆盖原头像</b></label><div class="tips2 C8d" style="padding-top:5px">如果想保留原头像只审核资料，这里可以不打勾，否则新头像将覆盖原头像</div></td>
    </tr>
    <?php }else{
		$btn_str='驳回';
		$btn_cls='HUI';
		$btn_confirm='驳回审核后将发送驳回信息（公众号通知和站内信），并引导用户重新修改';
	}?>
    <tr>
    <td class="tdL">审核意见</td>
    <td class="tdR"><textarea name="content" rows="3" class="textarea W100_" id="content" placeholder="请输入跟进反馈结果进行存档
    
如：【已电话沟通告知完善资料】，【此用户经常变动资料，小心】等"></textarea>
    </td>
    </tr>
    <tr>
      <td class="tdL">审核截图<br><font class="S12 C999">支持批量上传</font></td>
      <td class="tdR">
        <div class="picli60" id="picli_pathlist">
        	<li class="add" id="pathlist_add"></li>
			<?php
            if(!empty($pathlist)){
                $ARR=explode(',',$pathlist);
                $pathlist=array();
                foreach ($ARR as $V) {echo '<li><img src="'.$_ZEAI['up2'].'/'.$V.'"><i></i></li>';}
            }?>      
        </div>
      </td>
    </tr>
    </table>
    <div class="Mtop10 tiaose"><?php echo $btn_confirm;?></div>
    <input type="hidden" name="uid" value="<?php echo $uid;?>" />
    <input type="hidden" name="submitok" value="<?php echo $kind;?>_update" />
    <input name="pathlist" id="pathlist" type="hidden" value="" />
    <div class="savebtnbox"><button type="button" class="btn size3 <?php echo $btn_cls;?>" id="save">　<?php echo $btn_str;?>审核　</button></div>
	</form>
	<script>
		var up2='<?php echo $_ZEAI['up2'];?>/',upMaxMB=<?php echo $_UP['upMaxMB']; ?>,uid=<?php echo $uid; ?>;
		save.onclick=function(){
			window.parent.zeai.msg('处理中');
			zeai.ajax({url:'u_jb_list'+zeai.extname,form:GYLform},function(e){var rs=zeai.jsoneval(e);
				window.parent.zeai.msg(0);window.parent.zeai.msg(rs.msg);
				if(rs.flag==1){setTimeout(function(){window.parent.location.reload(true);},1000);}
			});
		}
		zeai.photoUp({
			btnobj:pathlist_add,
			upMaxMB:upMaxMB,
			url:"crm_gj_yj"+zeai.extname,
			multiple:8,
			submitok:"ajax_pic_path_s_up",
			end:function(rs){end();},
			li:function(rs){
				zeai.msg(0);zeai.msg(rs.msg);
				if (rs.flag == 1){picli_pathlist.append('<li><img src="'+up2+rs.dbname+'"><i></i></li>');}
			}
		});
		function end(){
			var i=zeai.tag(picli_pathlist,'i'),img=zeai.tag(picli_pathlist,'img');
			if(zeai.empty(i))return;
			for(var k=0;k<img.length;k++) {
				(function(k){
					var src=img[k].src;
					img[k].onclick = function(){parent.piczoom(src.replace('_s.','_b.'));}
				})(k);
			}
			for(var k=0;k<i.length;k++) {
				(function(k){
					i[k].onclick = function(){
						var thiss=this;
						zeai.confirm('亲~~确定删除么？',function(){
							thiss.parentNode.remove();
							pathlistReset();
						});
					}
				})(k);
			}
			function pathlistReset(){
				var img=zeai.tag(picli_pathlist,'img'),pathlist=[],src;
				for(var k=0;k<img.length;k++){
					var src=img[k].src.replace(up2,'');
					pathlist.push(src);
				}
				o('pathlist').value=pathlist.join(",");
			}
			pathlistReset();
		}
	</script>
<?php exit;}elseif($submitok=='shset'){
	$_ZEAI['data_nomodFlist']='photo_s,nickname,birthday,love,edu,heigh,pay';
	$data_nomodFlist=explode(',',$_ZEAI['data_nomodFlist']);
	$data_nomodF    =explode(',',$_ZEAI['data_nomodF']);
	?>
	<form id="GYLform">
    <table class="table W95_ Mtop20" style="margin:15px 0 0 15px">
    <tr>
    <td class="tdL">禁止修改</td>
    <td class="tdR">
    <?php 
	foreach ($data_nomodFlist as $F){
		$T=$FT[$F]['t'];
		$cls=(in_array($F,$data_nomodF))?' checked':'';?>
        <div class="shsetli"><input type="checkbox" name="nomodF[]" id="<?php echo $F;?>" class="checkskin " value="<?php echo $F;?>"<?php echo $cls;?>><label for="<?php echo $F;?>" class="checkskin-label"><i></i><b class="W80"><?php echo $T;?></b></label></div>
        <?php
	}
	?>
    </td>
    </tr>
    <tr>
    <td class="tdL">修改审核项目</td>
    <td class="tdR">
    <input type="radio" name="data_sh_item" id="data_sh_kind1" class="radioskin" value="all"<?php echo ($_ZEAI['data_sh_item'] == 'all')?' checked':'';?>><label for="data_sh_kind1" class="radioskin-label"><i></i><b class="W100">全部资料</b></label>
    <input type="radio" name="data_sh_item" id="data_sh_kind2" class="radioskin" value="text"<?php echo ($_ZEAI['data_sh_item'] == 'text')?' checked':'';?>><label for="data_sh_kind2" class="radioskin-label"><i></i><b class="W100">文本填写资料</b></label>
    </td>
    </tr>
    </table>
    <div class="savebtnbox"><button type="button" class="btn size3" id="save">　保存　</button></div>
    </form>
	<script>
    save.onclick=function(){
        var uu=<?php echo $session_uid;?>,pp='<?php echo $session_pwd;?>';
        zeai.ajax({url:'<?php echo HOST;?>/sub/cache'+zeai.extname,form:GYLform,data:{submitok:'cache_shset',uu:uu,pp:pp}},function(e){var rs=zeai.jsoneval(e);
            window.parent.zeai.msg(0);window.parent.zeai.msg(rs.msg);
            if(rs.flag==1){setTimeout(function(){window.parent.location.reload(true);},1000);}
        });
    }
    </script>
<?php exit;}elseif($submitok=='UdataSaveTip'){?>
	<form id="GYLform">
    <table class="table W95_ Mtop20" style="margin:15px 0 0 15px">
    <tr>
    <td class="tdL">提示内容<br><br><br><br><br></td>
    <td class="tdR">
    <textarea name="myinfo_SaveTip" rows="9" class="textarea W100_" style="font-family:宋体" id="myinfo_SaveTip" placeholder="请输入用户保存资料后提示语（请精简文字，50字内）"><?php echo dataIO($_ZEAI['myinfo_SaveTip'],'wx');?></textarea>
    <div class="tips2 C8d" style="padding-top:5px">
    插二维码图如：<input type="text" class="W200" value='<img src="图片网址">' style="border:0;background-color:#fff;font-family:宋体"><br>
    插入网址链接：<input type="text" class="W200" value='<a href="链接网址">文字</a>' style="border:0;background-color:#fff;font-family:宋体">
    </div></td>
    </tr>
    </table>
    <input type="hidden" name="submitok" value="myinfo_SaveTip_update" />
    <div class="savebtnbox"><button type="button" class="btn size3 <?php echo $btn_cls;?>" id="save">　保存　</button></div>
    </form>
<script>
save.onclick=function(){
	var uu=<?php echo $session_uid;?>,pp='<?php echo $session_pwd;?>';
	zeai.ajax({url:'<?php echo HOST;?>/sub/cache'+zeai.extname,form:GYLform,data:{submitok:'config_myinfo_SaveTip_update',uu:uu,pp:pp}},function(e){var rs=zeai.jsoneval(e);
		window.parent.zeai.msg(0);window.parent.zeai.msg(rs.msg);
		if(rs.flag==1){setTimeout(function(){window.parent.location.reload(true);},1000);}
	});
}
</script>
<?php exit;}?>

<?php 
/**CRM审核，匹配地区+门店**/
if(!in_array('crm',$QXARR) && $session_kind=='crm'){
	$SQLCRM .= " AND U.kind<>4 AND U.admid>0 ";
	$SQLCRM .= getAgentSQL('U');
}else{
	$SQLCRM = "";
}
/**CRM审核 结束**/
?>
<div class="box">
	<div class="boxL">
        <a href="u_jb_list.php" class="ed">资料审核</a>
        <a href="u_jb_list_bz.php">审核备注</a>
        <a href="wxewm.php">微信二维码</a>
	</div>
	<div class="boxR">
    	<div class="topsearch">
        <form id="Zeai_search_form" method="get" action="<?php echo SELF; ?>">
            <input name="Skey" type="text" id="Skey" size="30" maxlength="25" class="input size2 W250" placeholder="输入：UID/用户名/手机/姓名/昵称">
            <input type="hidden" name="p" value="<?php echo $p;?>" />
            <input type="hidden" name="dataflag" value="<?php echo $dataflag;?>" />
            <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
        </form>
        <div class="rbox">
            <a href="u_jb_list.php?dataflag=0"<?php echo (empty($dataflag))?' class="ed"':'';?>>未审核<?php
            if(empty($dataflag)){
                $rtt = $db->query("SELECT COUNT(*) FROM ".__TBL_USER__." U,".__TBL_SHALOU__." S WHERE U.id=S.uid AND (U.dataflag=0 OR S.photo_f=0) ".$SQLCRM);
                $rowt = $db->fetch_array($rtt);
                echo '<b>'.$rowt[0].'</b>';
            }
            ?></a>
            <a href="u_jb_list.php?dataflag=2"<?php echo ($dataflag==2)?' class="ed"':'';?>>被驳回<?php if($dataflag==2){
                $rtt = $db->query("SELECT COUNT(*) FROM ".__TBL_USER__." U,".__TBL_SHALOU__." S WHERE U.id=S.uid AND U.dataflag=2 ".$SQLCRM);
                $rowt = $db->fetch_array($rtt);
                echo '<b>'.$rowt[0].'</b>';
            }?></a>
            <?php if(in_array('crm',$QXARR)){?>
                <a href="javascript:UdataSaveTip();">温馨提示语</a>
                <a href="javascript:shset();">审核项目设置</a>
            <?php }?>
        </div>
		</div>
		<?php
        $sorthref = SELF."?dataflag=$dataflag&p=$p&sort=";
        if ($dataflag==2){
            $SQL = " AND U.dataflag=2";
        }else{
            $SQL = " AND (U.dataflag=0 OR S.photo_f=0) ";
        }
        $Skey = trimm($Skey);
        if (ifint($Skey)){
            $SQL .= " AND (U.id=$Skey) ";
        }elseif(!empty($Skey)){
            $SQL .= " AND ( ( U.uname LIKE '%".$Skey."%' ) OR ( U.mob LIKE '%".$Skey."%' )  OR ( U.truename LIKE '%".$Skey."%' ) OR ( U.nickname LIKE '%".$Skey."%' ) OR ( U.nickname LIKE '%".urlencode($Skey)."%' ) )";
        }
        switch ($sort) {
            case 'myinfobfb0':$SORT = " ORDER BY U.myinfobfb,U.id DESC ";break;
            case 'myinfobfb1':$SORT = " ORDER BY U.myinfobfb DESC,U.id DESC ";break;
            default:$SORT = " ORDER BY U.endtime DESC ";break;
        }
        $rt = $db->query("SELECT U.*,S.jsonstr,S.addtime,S.bz FROM ".__TBL_USER__." U,".__TBL_SHALOU__." S WHERE U.id=S.uid ".$SQL.$SQLCRM.$SORT);//." LIMIT 1"
        $total = $db->num_rows($rt);
        if ($total <= 0 ) {
            echo "<div class='nodataico'><i></i>暂无内容符合<br><a class='aQINGed' href='javascript:history.back(-1)'>返回上一步</a></div>";
        } else {
            $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';
        ?>
            <form id="www_zeai_cn_FORM">
            <table class="tablelist">
            <tr>
            <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
            <th width="120" align="left">UID<?php if(in_array('crm',$QXARR)){echo '/手机/昵称/认证';}?></th>
            <th width="65" align="center">原头像</th>
            <th width="65" align="center">原完善度
        <div class="sort">
            <a href="<?php echo $sorthref."myinfobfb0";?>" <?php echo($sort == 'myinfobfb0')?' class="ed"':''; ?>></a>
            <a href="<?php echo $sorthref."myinfobfb1";?>" <?php echo($sort == 'myinfobfb1')?' class="ed"':''; ?>></a>
        </div></th>
            <th width="60" align="center">公众号</th>
            <th align="center">帐号状态/注册-最近登录时间</th>
            <th width="65" align="center">新头像</th>
            <th width="65" align="center">新完善度</th>
            <th width="280" align="center">新资料</th>
            <th width="280" align="center">新要求</th>
            <th width="120" align="center">审核操作</th>
            <?php if ($dataflag == 0){?><?php }?>
            </tr>
            <?php
            for($i=1;$i<=$pagesize;$i++) {
                $rows = $db->fetch_array($rt,'name');
                if(!$rows) break;
                $id = $rows['id'];$uid = $id;
                $sex       = $rows['sex'];
                $grade     = $rows['grade'];
                $myinfobfb = $rows['myinfobfb'];
                $photo_s   = $rows['photo_s'];
                $RZZ       = $rows['RZ'];
                $subscribe = $rows['subscribe'];
				$regtime   = YmdHis($rows['regtime']);
				$endtime   = YmdHis($rows['endtime']);
				$flag      = $rows['flag'];
                $photo_s_url = (!empty($photo_s))?UP.smb($photo_s,'s'):RES.'photo_s'.$sex.'.png';
                $photo_s_str = '<img src="'.$photo_s_url.'">';
                //
                $row_shalou=json_decode($rows['jsonstr'],true);
                //同步沙漏
                if (!$row_shalou || count($row_shalou)<1 || empty($rows['jsonstr'])){
                    $row_shalou=shalou_init($uid);
                    set_data_ed_bfb($uid);
                }
                $sex_new     = $row_shalou['sex'];
                $photo_s_new = $row_shalou['photo_s'];
                $myinfobfb_new = get_shalou_ed_bfb($row_shalou);
                $photo_s_url_new = (!empty($photo_s_new))?UP.smb($photo_s_new,'s'):RES.'photo_s'.$sex_new.'.png';
                $photo_s_str_new = '<img src="'.$photo_s_url_new.'">';
            ?>
            <tr id="tr<?php echo $id;?>">
              <td width="20" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $uid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
              </td>
                <td width="120" align="left">
                <label for="id<?php echo $id; ?>"><?php echo uicon($sex.$grade).'<span class="textmiddle">'.$id.'</span>';?></label>
                <?php
                if(in_array('crm',$QXARR)){
                    $mob = trimhtml($rows['mob']);
                    $nickname = trimhtml(dataIO($rows['nickname'],'out'));
                    if(!empty($mob))echo '<div class="S12 C999 uleft"><a class="C999 baidumob" mob="'.$mob.'" title="手机归属地查询">'.$mob." <i class='ico'>&#xe624;</i></a></div>";
                    if(!empty($nickname))echo '<div class="S12 C999 uleft">'.$nickname."</div>";
                }?>
                <?php if(!empty($RZZ)){?><div title="手动点亮认证" uid="<?php echo $id;?>" class="forcerz"><?php echo RZ_html($RZZ,'s','color');?></div><?php }?>
                </td>
              <td width="65" align="center"><div class="photombox"><a href="javascript:;" class="noU58" onClick="parent.piczoom('<?php echo smb($photo_s_url,'b'); ?>');"><?php echo $photo_s_str; ?></a></div></td>
                <td width="65" align="center" class="S16">
                  <span class="<?php if($myinfobfb >80){echo ' myinfobfb2';}elseif($myinfobfb >20){echo ' myinfobfb1';}else{echo ' myinfobfb0';}?>"><?php echo $myinfobfb;?>%</span>
                </td>
                <td width="60" align="center" class="C999"><?php
        if($subscribe==0){
            echo '<span class="C999"></span>';
        }elseif($subscribe==1){
            echo '<i class="ico S14 wxlv">&#xe6b1;</i>';
        }else{
            echo '<span class="C00f">取消</span>';
        }
        ?></td>
              <td align="center" class="jt C999"><div><?php echo flagtitle($flag);?></div>注册:<?php echo $regtime;?><br><i class="ico">&#xe62d;</i><br>最近:<?php echo $endtime;?></td>
                <td width="65" align="center">
                    <div class="photombox">
                      <a href="javascript:;" class="noU58 sex<?php echo $sex_new; ?>" onClick="parent.piczoom('<?php echo smb($photo_s_url_new,'b'); ?>');"><?php echo $photo_s_str_new; ?></a>
                        <?php if (!empty($photo_s_new)){?><a href="javascript:;" class="del" uid="<?php echo $uid;?>" title="删除头像"></a><?php }?>
                    </div>
                    <?php if (!empty($photo_s_new)){?><a href="javascript:cut(<?php echo $uid; ?>,'<?php echo urlencode($uid); ?>','<?php echo $p; ?>');" class="btn size1 cut" title="裁切头像">裁切头像</a><?php }?>
                </td>
                <td width="65" align="center" class="S16"><span class="<?php if($myinfobfb_new >80){echo ' myinfobfb2';}elseif($myinfobfb_new >20){echo ' myinfobfb1';}else{echo ' myinfobfb0';}?>"><?php echo $myinfobfb_new;?>%</span></td>
                <td width="280" align="center" class="C999 lineH200" style="padding:10px 0">
                <!---->
                <ul class="datali">
                <?php 
                    $mateshowflag=0;
                    $zoyqstr='';
                    foreach ($row_shalou as $F=>$V) {
                        if($rows[$F] == $V)continue;
                        $ismodclas=($rows[$F] != $V)?' class="ismod"':' class="nomod"';
                        $T = $FT[$F]['t'];
                        $S = $FT[$F]['s'];
                        if(empty($V) || $F=='photo_s' || $F=='mate_areaid' || $F=='mate_areaid2' ||  $F=='areaid'||  $F=='area2id' ||  $F=='mate_age1' ||  $F=='mate_heigh1' ||  $F=='mate_weigh1')continue;
                        if(strstr($F,'mate_')){
                            $F2 = str_replace("mate_","",$F);
                        }else{
                            $F2 = $F;
                        }
                        switch ($S) {//1:文本,2:单选,3:复选,4:区间,5:特殊
                            default://1,4,5
                                switch ($F) {
                                    case 'heigh':
                                        $DATAlod_str = udata('heigh',$rows[$F]);
                                        $DATAnew_str = udata('heigh',$V);
                                    break;
                                    case 'weigh':
                                        $DATAlod_str = udata('weigh',$rows[$F]);
                                        $DATAnew_str = udata('weigh',$V);
                                    break;
                                    case 'tag':
                                        $DATAlod_str = udata('tag'.$rows['sex'],$rows[$F]);
                                        $DATAnew_str = udata('tag'.$row_shalou['sex'],$V);
                                    break;
                                    case 'mate_age2':
                                        $DATAlod_str = $rows['mate_age1'].'～'.$rows['mate_age2'].'岁';
                                        $DATAnew_str = $row_shalou['mate_age1'].'～'.$row_shalou['mate_age2'].'岁';;
                                    break;
                                    case 'mate_heigh2':
                                        $DATAlod_str = $rows['mate_heigh1'].'～'.udata('heigh',$rows['mate_heigh2']);
                                        $DATAnew_str = $row_shalou['mate_heigh1'].'～'.udata('heigh',$row_shalou['mate_heigh2']);
                                    break;
                                    case 'mate_weigh2':
                                        $DATAlod_str = $rows['mate_weigh1'].'～'.udata('weigh',$rows['mate_weigh2']);
                                        $DATAnew_str = $row_shalou['mate_weigh1'].'～'.udata('weigh',$row_shalou['mate_weigh2']);
                                    break;
                                    case 'nickname':
                                        $DATAlod_str = uicon($sex.$grade).trimhtml(dataIO($rows[$F],'out'),'keep_rn');
                                        $DATAnew_str = uicon($sex_new.$grade).trimhtml(dataIO($V,'wx'),'keep_rn');
                                    break;
                                    default:
                                        $DATAlod_str = trimhtml(dataIO($rows[$F],'out'),'keep_rn');
                                        $DATAnew_str = trimhtml(dataIO($V,'wx'),'keep_rn');
                                    break;
                                }
                            break;
                            case 2:
                                $DATAlod_str = udata($F2,$rows[$F]);
                                $DATAnew_str = udata($F2,$V);
                            break;
                            case 3:
                                $DATAlod_str = udata($F2,$rows[$F]);
                                $DATAnew_str = udata($F2,$V);
                            break;
                        }
                        if(strstr($F,'mate_')){
                            $mateshowflag=1;
                            //择偶要求
                            $zoyqstr.='<li>'.$T.'：'.$DATAnew_str.'</li>';
                        }elseif($F=='weixin_pic' && !empty($DATAnew_str)){?>	
                            <a href="javascript:;" class="noU58 FR" title="<?php echo $T;?>" onClick="top.piczoom('<?php echo UP.$DATAnew_str; ?>');"><img src="<?php echo UP.$DATAnew_str;?>"></a>
                            <?php	
                        }else{
                            echo '<li>'.$T.'：'.$DATAnew_str.'</li>';
                        }
                    }
                    ?>
                </ul>
                <!---->
            </td>
            <td width="280" align="center" class="C999 lineH200" style="padding:10px 0"><ul class="datali mate"><?php echo $zoyqstr;?></ul></td>
            <td width="120" align="center" class="padding10">
                <a href="javascript:;" class="W80 btn size2 BAI dataedit" title='修改资料'  uid="<?php echo $uid;?>" title2="<?php echo urlencode(trimhtml($nickname.' ｜ '.$uid));?>">修改资料</a><br><br>
                <a href="javascript:;" title="详细对比" class="W80 btn size2 BAI detaildata" uid="<?php echo $uid; ?>" nickname="<?php echo urlencode($nickname);?>">详细比对</a><br><br>
                <a href="javascript:;" title="审核" class="W80 btn size2  dataflag1" uid="<?php echo $uid; ?>" nickname="<?php echo urlencode($nickname);?>">通过审核</a><br><br>
                <a href="javascript:;" title="拒绝" class="W80 btn size HUI dataflag2" uid="<?php echo $uid; ?>" nickname="<?php echo urlencode($nickname);?>">驳回</a>
            </td>
            </tr>
            <?php } ?>
        </table>
        </form>
        <?php } ?>
	</div>
    <div class="clear"></div>
</div>
<?php  if ($total > 0 ) {?>
<div class="listbottombox">
	<input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
    <button type="button" id="btndellist" class="btn size2 HEI2 disabled action">批量驳回</button>　
    <button type="button" id="btnflaglist" class="btn size2 LV disabled action">批量审核</button>　
    <button type="button" id="btnsend" value="" class="btn size2 disabled action" onClick="sendTipFn2(this);"><i class="ico">&#xe676;</i> 发送消息</button>
    <input type="hidden" name="submitok" id="submitok" value="" />
	<?php if ($total > $pagesize)echo '<div class="pagebox FR">'.$pagelist.'</div>'; ?>
</div>
<script>
var bg = '<?php echo $_Style['list_bg']; ?>',overbg   = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
/*头像处理*/
zeai.listEach('.photo_mflag1',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid")),nickname=obj.getAttribute("nickname");
		zeai.confirm('确定要审核【'+decodeURIComponent(nickname)+'】头像么？',function(){
			zeai.msg('正在审核处理【'+decodeURIComponent(nickname)+'】',{time:300});
			zeai.ajax('photo_m'+zeai.ajxext+'submitok=allflag1&list[]='+uid,function(e){var rs=zeai.jsoneval(e);
				if (rs.flag == 1){location.reload(true);}else{zeai.msg(0);zeai.msg(rs.msg,{time:1});}
			});
		});
	}
});
zeai.listEach('.del',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid"));
		zeai.confirm('<b class="S16">真的要删除头像么</b>？<br>删除后将自动发送驳回信息（微信和站内信），引导用户重新上传',function(){
			zeai.ajax('u_jb_list'+zeai.ajxext+'submitok=photo_s_shalou_del&uid='+uid,function(e){var rs=zeai.jsoneval(e);
				if (rs.flag == 1){location.reload(true);}else{zeai.msg(rs.msg);}
			});
		});
	}
});



/*批量审无备注*/
o('btndellist').onclick = function() {
	allList({
		btnobj:this,
		url:'u_jb_list'+zeai.ajxext+'submitok=dataflag2',
		title:'批量驳回',
		content:'批量驳回（无需备注）后将同步批量发送（微信和站内信），请不要关闭窗口耐心等待。',
		msg:'驳回处理中...',
		ifjson:true,
		ifconfirm:true
	});	
}
o('btnflaglist').onclick = function() {
	allList({
		btnobj:this,
		url:'u_jb_list'+zeai.ajxext+'submitok=dataflag1',
		title:'批量审核',
		content:'<div class="Cf00">此审核将连同头像一起审核并覆盖原头像（无需备注）</div><br>将同步批量发送（微信和站内信），请不要关闭窗口耐心等待。',
		msg:'审核处理中...',
		ifjson:true,
		ifconfirm:true
	});	
}

/*单审有备注*/
zeai.listEach('.dataflag1',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid"));
		zeai.iframe('【UID：'+uid+'】审核/反馈备注','u_jb_list'+zeai.ajxext+'submitok=bz&kind=dataflag1&uid='+uid,700,440);
		//zeai.confirm('<b class="S16">确定要审核【'+uid+'】么</b>？<br>审核成功后将同步覆盖原资料',function(){
			
		//});
	}
});
zeai.listEach('.dataflag2',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid"));
		zeai.iframe('【UID：'+uid+'】驳回/反馈原因','u_jb_list'+zeai.ajxext+'submitok=bz&kind=dataflag2&uid='+uid,700,400);
		//zeai.confirm('<b class="S16">真的要驳回【'+uid+'】个人资料么</b>？',function(){
			
		//});
	}
});

zeai.listEach('.dataedit',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid")),title2=obj.getAttribute("title2");
		zeai.iframe('修改【'+decodeURIComponent(title2)+'】资料','u_mod_data.php?submitok=mod&ifmini=1&t=2&uid='+uid);
	}
});
function cut(id,nkname,p) {zeai.iframe('裁切【'+nkname+'】主头像','u_photo_cut.php?ifm=shalou&id='+id+'&submitok=www___zeai__cn_inphotocut'+'&p='+p,650,560);}
zeai.listEach('.detaildata',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid"));
		title2 = obj.getAttribute("title2"),
		zeai.iframe('【'+uid+'】审核沙漏：新老数据详细比对','u_jb_list_detail.php?uid='+uid);
	}
});
zeai.listEach('.baidumob',function(obj){
	obj.onclick = function(){
		var mob = obj.getAttribute("mob");
		zeai.openurl_('https://www.baidu.com/s?wd='+mob);
		//zeai.iframe('【'+mob+'】归属地查询','https://www.baidu.com/s?wd='+mob,400,320);
	}
});
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }
require_once 'bottomadm.php';?>
